create or replace function DepartmentType2XML(integer, text)
returns xml
as
$$
	declare
		departmentTypeId alias for $1;
		departmentTypeName alias for $2;
	begin
		return
			xmlelement(
				name departmenttype, xmlattributes(departmentTypeId as id),
				xmlelement(name departmenttypename, departmentTypeName)
			);
	end;
$$ language plpgsql immutable; -- same result for same data